package com.jiejie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jiejie.entity.Schedule;
import com.jiejie.mapper.ScheduleMapper;
import com.jiejie.service.IScheduleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 辰广
 * @since 2022-10-05
 */
@Service
public class ScheduleServiceImpl extends ServiceImpl<ScheduleMapper, Schedule> implements IScheduleService {

    @Resource
    private ScheduleMapper scheduleMapper;
    @Override
    public List<Schedule> getScheduleByMovieId(Integer movieId, LocalDate scheduleDate) {
        System.out.println("movieId:"+movieId+",scheduleDate:"+scheduleDate);
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("movie_id",movieId);
        queryWrapper.eq("schedule_status",1);
        queryWrapper.eq("schedule_begin_date",scheduleDate);
        queryWrapper.gt("schedule_begin_time", LocalTime.now());
        queryWrapper.orderByAsc("schedule_begin_time");
        List<Schedule> scheduleList=scheduleMapper.selectList(queryWrapper);
        System.out.println("scheduleList:"+scheduleList);
        return scheduleList;
    }
}
